<% content_for :sitemap do %>
  <span class="current">OAuth Applications</span>
<% end %>
<div class="toolbar">
  <form class="form-inline" action="<%= admin_applications_path %>">
    <input type="text" name="q" class="form-control" value="<%= params[:q] %>" placeholder="Name">
    <%= select_tag(:level, options_for_select([['All Level',''], ['Level 0', 0], ['Level 1', 1], ['Level 2', 2], ['Level 3', 3]], params[:level]), class: 'form-control') %>
    <button class="btn btn-secondary">Search</button>
  </form>
</div>
<div id="admin_applications">
  <table class="table">
    <tr class="head">
      <th>ID</th>
      <th>Name</th>
      <th>Uid</th>
      <th>Owner</th>
      <th>Tokens</th>
      <th>Level</th>
      <th>Time</th>
      <th></th>
    </tr>
    <% @applications.each do |item| %>
      <tr class="<%= cycle("","even") %>">
        <td><%= item.id %></td>
        <td><%= link_to item.name, admin_application_path(item.id) %></td>
        <td><%= item.uid %></td>
        <td><%= user_name_tag(item.owner) %></td>
        <td><%= item.access_tokens.count %></td>
        <td><%= item.level %></td>
        <td><%= l(item.created_at, format: :long) %></td>
        <td class="actions">
          <div class="btn-group">
            <%= link_to icon_tag("pencil"), edit_admin_application_path(item), class: "btn" %>
          </div>
        </td>
      </tr>
    <% end %>
  </table>
  <%= paginate @applications %>
</div>
